package cn.iocoder.yudao.module.ems.dal.mysql.equipment;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.ems.controller.admin.supplier.vo.SupplierListReqVO;
import cn.iocoder.yudao.module.ems.dal.dataobject.equipment.EquipmentDO;
import cn.iocoder.yudao.module.ems.dal.dataobject.supplier.SupplierDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.ems.controller.admin.equipment.vo.*;

/**
 * 设备 Mapper
 *
 * @author 左达成
 */
@Mapper
public interface EquipmentMapper extends BaseMapperX<EquipmentDO> {

    default PageResult<EquipmentDO> selectPage(EquipmentPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<EquipmentDO>()
                .eqIfPresent(EquipmentDO::getAssetNo, reqVO.getAssetNo())
                .likeIfPresent(EquipmentDO::getName, reqVO.getName())
                .eqIfPresent(EquipmentDO::getTypeId, reqVO.getTypeId())
                .eqIfPresent(EquipmentDO::getEqStatus, reqVO.getEqStatus())
                .eqIfPresent(EquipmentDO::getUsageStatus, reqVO.getUsageStatus())
                .eqIfPresent(EquipmentDO::getLevel, reqVO.getLevel())
                .eqIfPresent(EquipmentDO::getSerialNo, reqVO.getSerialNo())
                .eqIfPresent(EquipmentDO::getPersonLiable, reqVO.getPersonLiable())
                .eqIfPresent(EquipmentDO::getDeptId, reqVO.getDeptId())
                .eqIfPresent(EquipmentDO::getBrand, reqVO.getBrand())
                .eqIfPresent(EquipmentDO::getSupplierId, reqVO.getSupplierId())
                .betweenIfPresent(EquipmentDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(EquipmentDO::getId));
    }

    default List<EquipmentDO> selectList(EquipmentExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<EquipmentDO>()
                .eqIfPresent(EquipmentDO::getAssetNo, reqVO.getAssetNo())
                .likeIfPresent(EquipmentDO::getName, reqVO.getName())
                .eqIfPresent(EquipmentDO::getTypeId, reqVO.getTypeId())
                .eqIfPresent(EquipmentDO::getEqStatus, reqVO.getEqStatus())
                .eqIfPresent(EquipmentDO::getUsageStatus, reqVO.getUsageStatus())
                .eqIfPresent(EquipmentDO::getLevel, reqVO.getLevel())
                .eqIfPresent(EquipmentDO::getSerialNo, reqVO.getSerialNo())
                .eqIfPresent(EquipmentDO::getPersonLiable, reqVO.getPersonLiable())
                .eqIfPresent(EquipmentDO::getDeptId, reqVO.getDeptId())
                .eqIfPresent(EquipmentDO::getBrand, reqVO.getBrand())
                .eqIfPresent(EquipmentDO::getSupplierId, reqVO.getSupplierId())
                .betweenIfPresent(EquipmentDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(EquipmentDO::getId));
    }

    default List<EquipmentDO> selectList(EquipmentListReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<EquipmentDO>()
                .likeIfPresent(EquipmentDO::getName, reqVO.getName()));
    }

}
